/*
 * StatusView.java
 *
 * Created on 12 Август 2010 г., 21:26
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.jimm.protocol;

import org.jimm.app.JimmApplication;
import org.jimm.app.R;
import org.jimm.protocol.icq.Icq;

import android.app.Dialog;


/**
 * @author Vladimir Kryukov
 */
public class StatusView {
    public static final int INFO_MENU_COPY = 1;
    public static final int INFO_MENU_COPY_ALL = 2;
    public static final int INFO_MENU_GOTO_URL = 4;
    public static final int INFO_MENU_GET_X = 5;
    private Protocol protocol;
    private Contact contact;
    private Dialog dialog;


    /**
     * Creates a new instance of StatusView
     */
    public StatusView(Protocol p, Contact c) {
        dialog = new Dialog(JimmApplication.getInstance().getService().getCurrentActivity());
        dialog.setContentView(R.layout.contact_info);

        contact = c;
        protocol = p;
        dialog.setTitle(contact.getName());
//        addInfo(protocol.getUserIdName(), contact.getUserId());
    }

    public void select(int cmd) {
        switch (cmd) {
            case INFO_MENU_COPY:
            case INFO_MENU_COPY_ALL:
//                copy(INFO_MENU_COPY_ALL == cmd);
//                restore();
                break;


//            case INFO_MENU_GOTO_URL:
//                new TextListEx("").gotoURL(getCurrText());
//                break;
//                
            // #sijapp cond.if protocols_ICQ is "true" #
            case INFO_MENU_GET_X:
                ((Icq)protocol).requestXStatusMessage(this, contact);
//                restore();
                break;
            // #sijapp cond.end #
        }
    }

    // #sijapp cond.if modules_CLIENTS is "true" #
//    public void addClient(Icon icon, String name) {
//        addPlain(icon, name);
//    }
    // #sijapp cond.end #
    /////////////////////
//    public void addBr() {
//        Parser line = createParser(-1);
//        line.addText(" \n", THEME_TEXT, FONT_STYLE_PLAIN);
//        addPar(line);
//    }
//    public void addPlain(Icon img, String str) {
//        if (!StringConvertor.isEmpty(str)) {
//            int id = uiBigTextIndex++;
//            Parser line = createParser(id);
//            if (null != img) {
//                line.addImage(img);
//            }
//            line.addText(str, THEME_TEXT, FONT_STYLE_PLAIN);
//            addPar(line);
//        }
//    }
    public void addStatusText(String text) {
//        if (!StringConvertor.isEmpty(text)) {
//            int id = uiBigTextIndex++;
//            Parser line = createParser(id);
//            line.addText(text, THEME_PARAM_VALUE, FONT_STYLE_PLAIN);
//            addPar(line);
//        }
    }

    public void addInfo(String key, String value) {
//        addParam(key, value);
    }

    /////////////////////
    public void addContactStatus() {
//        byte status = contact.getStatusIndex();
//        StatusInfo info = protocol.getStatusInfo();
//        addStatus(info.getIcon(status), info.getName(status));
    }

    // #sijapp cond.if modules_XSTATUSES is "true" #
    public void addXStatus() {
//        XStatusInfo info = protocol.getXStatusInfo();
//        int x = contact.getXStatusIndex();
//        addStatus(info.getIcon(x), info.getName(x));
    }

    // #sijapp cond.end #
    public void addStatus(int icon, String name) {
//        addPlain(icon, name);
    }
//    protected MenuModel getMenu() {
//        MenuModel menu = new MenuModel();
//        menu.addItem("copy_text",     INFO_MENU_COPY);
//        menu.addItem("copy_all_text", INFO_MENU_COPY_ALL);
//        if ((1 < getCurrTextIndex()) && Util.hasURL(getCurrText())) {
//            menu.addItem("goto_url", INFO_MENU_GOTO_URL);
//        }
//        // #sijapp cond.if protocols_ICQ is "true" #
//        if ((XStatusInfo.XSTATUS_NONE != contact.getXStatusIndex())
//                && (protocol instanceof Icq)) {
//            menu.addItem("reqxstatmsg", INFO_MENU_GET_X);
//        }
//        // #sijapp cond.end #
//        menu.setActionListener(this);
//        return menu;
//    }

    public Contact getContact() {
        return contact;
    }

    public void showIt() {
        dialog.show();
    }
}
